Skip to content

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented Nov 18, 2025

This is first draft. I might be assuming too much familiarity with the problem space. Please provide feedback 🤝


Internal previews

📄 File 🔗 Preview link
docs/standard/library-guidance/dependencies-net.md docs/standard/library-guidance/dependencies-net

Added guidance for selecting .NET library dependency versions, including strategies, tradeoffs, and recommendations for library authors.
@ericstj ericstj requested a review from JamesNK as a code owner November 18, 2025 20:08
Copilot AI review requested due to automatic review settings November 18, 2025 20:08
@ericstj ericstj requested review from a team and IEvangelist as code owners November 18, 2025 20:08
@dotnetrepoman dotnetrepoman bot added this to the November 2025 milestone Nov 18, 2025
Copilot finished reviewing on behalf of ericstj November 18, 2025 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces comprehensive guidance for .NET library authors on selecting dependency versions when targeting multiple .NET framework versions. The document outlines three primary strategies (latest supported versions, TFM-specific versions, and branching), their tradeoffs, and provides concrete recommendations with code examples.

Key changes:

  • New guidance document explaining dependency version selection strategies for .NET libraries.
  • Decision matrix comparing engineering, servicing, and update friction costs across strategies.
  • Code examples demonstrating each approach using System.Text.Json references.

Show contrast to framework overlapping package and not.
@ericstj
Copy link
Member Author

ericstj commented Nov 24, 2025

I've addressed all feedback, please have another pass at this. Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add this to the TOC somewhere. Maybe below this article in this file?

@@ -0,0 +1,171 @@
---
ai-usage: ai-assisted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ai-usage: ai-assisted
title: Guidance for .NET library dependency versions
description: Learn about the strategies and recommendations for choosing dependency versions when you build a library that targets multiple .NET versions.
ms.date: 11/24/2025
ai-usage: ai-assisted

Comment on lines +6 to +8
When building libraries that target multiple .NET versions, choosing dependency versions has implications for compatibility, servicing, and ecosystem health. This document outlines the main strategies, their tradeoffs, and recommendations.

---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When building libraries that target multiple .NET versions, choosing dependency versions has implications for compatibility, servicing, and ecosystem health. This document outlines the main strategies, their tradeoffs, and recommendations.
---
When you build libraries that target multiple .NET versions, choosing dependency versions has implications for compatibility, servicing, and ecosystem health. This article outlines the main strategies, their tradeoffs, and recommendations.


---

## **Overview**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## **Overview**
## Overview


## **Overview**

Library authors face challenges when deciding which version of a .NET dependency to reference. Newer versions have more API and features, but may require a local redistribution increasing servicing responsibilities of the library and size of the application. The decision impacts:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Library authors face challenges when deciding which version of a .NET dependency to reference. Newer versions have more API and features, but may require a local redistribution increasing servicing responsibilities of the library and size of the application. The decision impacts:
Library authors face challenges when deciding which version of a .NET dependency to reference. Newer versions have more APIs and features but might require a local redistribution, which increases servicing responsibilities of the library and size of the application. The decision impacts:

## **Examples**

### Example 1: Latest supported version
```xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```xml
```xml

```

### Example 2: TFM-specific versions
```xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```xml
```xml

```

### Example 3: Branching
Branch: release/8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Branch: release/8.0
Branch: release/8.0

</ItemGroup>
```

Branch: release/9.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Branch: release/9.0
Branch: release/9.0

</ItemGroup>
```

Branch: release/10.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Branch: release/10.0
Branch: release/10.0

<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net8.0'" Include="System.IO.Packaging" Version="8.0.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I wasn't clear earlier about the example.

I think a good example here would be Microsoft.Extensions.Logging.Abstractions. It isn't in the shared framework, but lifts a dependency on a library that is in the shared framework.

https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions/#dependencies-body-tab

Image

If a library references the 10.0.0 version of Microsoft.Extensions.Logging.Abstractions, System.Diagnostics.DiagnosticSource will be lifted out of the shared framework for all net8 and net9 apps that reference the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants